package com.wgo.precise.client.ui.view.projecttree;

import org.eclipse.jface.resource.ImageDescriptor;

import com.wgo.precise.client.ui.model.facade.IModelPersistable;
import com.wgo.precise.client.ui.view.util.ViewerAction;


/**
 * 
 * @author Petter L. H. Eide
 * @version $Id: CrudAction.java,v 1.2 2006-01-30 21:52:33 petterei Exp $
 */
public abstract class CrudAction<T extends IModelPersistable> extends ViewerAction {

    private T item;

    protected CrudAction(String text, T item, ImageDescriptor image){
        super(text, image);
    	init(item);
    }
    private void init(@SuppressWarnings("hiding") T item){
        showDisplayMessage(false);
        this.item = item;
        String message = "";
        if (item != null) {
            message = item.getClass().getSimpleName() + ": " + item.getText();
        }
        setToolTipText(getText()+ ": " +  message);
        setMessage(message);
    }

    protected T getItem() {
        return item;
    }
    protected void setItem(T item){
        this.item = item;
    }
    protected boolean isTextSet() {
        return (getText() != null);
    }
	@Override
	public void run() {
		super.run();
		item = null; // clean up..
	}
    
}
/**
 * 
 * Changelog:
 * 
 * $Log: CrudAction.java,v $
 * Revision 1.2  2006-01-30 21:52:33  petterei
 * implemented wrapper factory and lazy wrapper-instantiation of parents
 * implemented a "system" for each top-node type
 * added top-categories for all top-nodes
 * implemented some interfaces for the wrappers, and started using these
 *
 * Revision 1.1  2006-01-23 19:58:38  petterei
 * initial commit for client, fitting the alternative session implementation
 *
 * Revision 1.5  2006-01-13 08:13:00  petterei
 * Using Long consequently to differentiate between �null� and �0� for dbId and conceptId (no boxing/unboxing)
 * Ajusted code to stronger java-syntax
 *
 * Revision 1.4  2005-12-14 20:27:21  petterei
 * added custom images
 *
 * Revision 1.3  2005-12-14 08:22:04  petterei
 * -refactored: new categories inherit propertysets from parent category, requirements-propertysets is only retrieved from parent category (before: no "physical" category inheritance, but requirement got propertysets from all categoryparents)
 * -cleaned up some code and configfiles, minor refactoring
 *
 * Revision 1.2  2005-12-13 12:10:54  petterei
 * refactorin + bugfix
 *
 * Revision 1.1  2005/09/27 21:06:18  petterei
 * *** empty log message ***
 *
 * Revision 1.5  2005/09/27 17:06:19  petterei
 * *** empty log message ***
 *
 * Revision 1.4  2005/08/25 18:14:26  peide3
 * updated services interface
 *
 * Revision 1.3  2005/08/23 06:40:47  peide3
 * *** empty log message ***
 *
 * Revision 1.2  2005/08/09 09:24:06  petterei
 * *** empty log message ***
 *
 * Revision 1.1  2005/07/31 22:55:09  petterei
 * initial commit
 *
 * Revision 1.2  2005/07/20 08:48:40  peide3
 * updated and implemented more functionality
 *
 * Revision 1.1  2005/07/20 06:06:39  peide3
 * implemented Eclipse-IActions
 *
 */
